/*
 * UDPServer.hpp
 *
 *  Created on: Dec 29, 2014
 *      Author: toti
 */

#ifndef UDPSERVER_HPP_
#define UDPSERVER_HPP_

#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <stdlib.h>
#include <string.h>

#include <string>
#include <sstream>

class UDPServer{

private:

	std::string listeningAddress;
	std::string port;

	int sock;
	struct sockaddr_in6 sender;
	struct addrinfo*  multicastAddr;     /* Multicast Address */
	struct addrinfo*  localAddr;         /* Local address to bind to */
	struct addrinfo   hints  = { 0 };    /* Hints for name lookup */

	void init();

public:

	char buffer[64];

	UDPServer(std::string &listeningAddress, std::string &port);

	int receiveDatagram(size_t len, void *data);

	int getSock();

};


#endif /* UDPSERVER_HPP_ */
